package com.starview.star.operators.arith.runtime;

import com.starview.platform.data.EvaluationException;
import com.starview.platform.data.IFunction;
import com.starview.platform.data.IValue;
import com.starview.platform.data.type.IType;
import com.starview.platform.data.type.StandardTypes;
import com.starview.platform.data.type.TypeUtils;
import com.starview.platform.data.value.Factory;
import com.starview.star.operators.CafeEnter;

public abstract class LongUnary
{

  public static class LongAbs implements IFunction
  {
    @CafeEnter
    public static long enter(long s1)
    {
      return Math.abs(s1);
    }

    @Override
    public IType getType()
    {
      IType longType = StandardTypes.rawLongType;
      return TypeUtils.functionType(longType, longType);
    }

    @Override
    public IValue enter(IValue... args) throws EvaluationException
    {
      return Factory.newLng(enter(Factory.lngValue(args[0])));
    }
  }

  public static class LongUMinus implements IFunction
  {
    @CafeEnter
    public static long enter(long s1)
    {
      return -s1;
    }

    @Override
    public IType getType()
    {
      IType longType = StandardTypes.rawLongType;
      return TypeUtils.functionType(longType, longType);
    }

    @Override
    public IValue enter(IValue... args) throws EvaluationException
    {
      return Factory.newLng(enter(Factory.lngValue(args[0])));
    }
  }

  public static class LongRandom implements IFunction
  {
    @CafeEnter
    public static long enter(long s1)
    {
      double random = Math.random();
      return new Double(random * s1).longValue();
    }

    @Override
    public IType getType()
    {
      IType longType = StandardTypes.rawLongType;
      return TypeUtils.functionType(longType, longType);
    }

    @Override
    public IValue enter(IValue... args) throws EvaluationException
    {
      return Factory.newLng(enter(Factory.lngValue(args[0])));
    }
  }

  public static class LongSqrt implements IFunction
  {
    @CafeEnter
    public static long enter(long s1)
    {
      return (long) Math.sqrt(s1);
    }

    @Override
    public IType getType()
    {
      IType longType = StandardTypes.rawLongType;
      return TypeUtils.functionType(longType, longType);
    }

    @Override
    public IValue enter(IValue... args) throws EvaluationException
    {
      return Factory.newLng(enter(Factory.lngValue(args[0])));
    }
  }

  public static class LongCbrt implements IFunction
  {
    @CafeEnter
    public static long enter(long s1)
    {
      return (long) Math.cbrt(s1);
    }

    @Override
    public IType getType()
    {
      IType longType = StandardTypes.rawLongType;
      return TypeUtils.functionType(longType, longType);
    }

    @Override
    public IValue enter(IValue... args) throws EvaluationException
    {
      return Factory.newLng(enter(Factory.lngValue(args[0])));
    }
  }

  public static class LongCeil implements IFunction
  {
    @CafeEnter
    public static long enter(long s1)
    {
      return s1;
    }

    @Override
    public IType getType()
    {
      IType longType = StandardTypes.rawLongType;
      return TypeUtils.functionType(longType, longType);
    }

    @Override
    public IValue enter(IValue... args) throws EvaluationException
    {
      return Factory.newLng(enter(Factory.lngValue(args[0])));
    }
  }

  public static class LongFloor implements IFunction
  {
    @CafeEnter
    public static long enter(long s1)
    {
      return s1;
    }

    @Override
    public IType getType()
    {
      IType longType = StandardTypes.rawLongType;
      return TypeUtils.functionType(longType, longType);
    }

    @Override
    public IValue enter(IValue... args) throws EvaluationException
    {
      return Factory.newLng(enter(Factory.lngValue(args[0])));
    }
  }

  public static class LongRound implements IFunction
  {
    @CafeEnter
    public static long enter(long s1)
    {
      return s1;
    }

    @Override
    public IType getType()
    {
      IType longType = StandardTypes.rawLongType;
      return TypeUtils.functionType(longType, longType);
    }

    @Override
    public IValue enter(IValue... args) throws EvaluationException
    {
      return Factory.newLng(enter(Factory.lngValue(args[0])));
    }
  }

  public static class LongLog implements IFunction
  {
    @CafeEnter
    public static long enter(long s1)
    {
      return (long) Math.log(s1);
    }

    @Override
    public IType getType()
    {
      IType longType = StandardTypes.rawLongType;
      return TypeUtils.functionType(longType, longType);
    }

    @Override
    public IValue enter(IValue... args) throws EvaluationException
    {
      return Factory.newLng(enter(Factory.lngValue(args[0])));
    }
  }

  public static class LongLog10 implements IFunction
  {
    @CafeEnter
    public static long enter(long s1)
    {
      return (long) Math.log10(s1);
    }

    @Override
    public IType getType()
    {
      IType longType = StandardTypes.rawLongType;
      return TypeUtils.functionType(longType, longType);
    }

    @Override
    public IValue enter(IValue... args) throws EvaluationException
    {
      return Factory.newLng(enter(Factory.lngValue(args[0])));
    }
  }

  public static class LongExp implements IFunction
  {
    @CafeEnter
    public static long enter(long s1)
    {
      return (long) Math.exp(s1);
    }

    @Override
    public IType getType()
    {
      IType longType = StandardTypes.rawLongType;
      return TypeUtils.functionType(longType, longType);
    }

    @Override
    public IValue enter(IValue... args) throws EvaluationException
    {
      return Factory.newLng(enter(Factory.lngValue(args[0])));
    }
  }
}
